﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace PFM.Entities
{
    [DataContract]
    public abstract  class EntityBase:CoolCode.DataSource.IEntity
    {
        [DataMember]
        public Guid Guid { get; set; }
        [DataMember]
        public Guid CreateUserUID { get; set; }
        [DataMember]
        public Guid LastUpdateUserUID { get; set; }
        [DataMember]
        public DateTime CreateDate { get; set; }
        [DataMember]
        public DateTime LastUpdateDate { get; set; }
        
        public EntityBase() : this(Guid.NewGuid()) { }

        //public EntityBase(IUser _user) : this(_user.UID) { }

        public EntityBase(Guid  _CreateUserUID)
        {
            this.Guid = Guid.NewGuid();
            CreateUserUID = _CreateUserUID;
            LastUpdateUserUID = _CreateUserUID;
            CreateDate = DateTime.Now;
            LastUpdateDate = DateTime.Now; 

        }

        public override string ToString()
        {
            return string.Format( "Guid:{0}, Create ID:{1}, Date:{2}",Guid ,CreateUserUID ,CreateDate );
        }
    }
}
